var g_oEditorContainer;

/**
	fired when the ondatachange event occurs,
	send the server a message that one data has changed with the data identity and value after change.
 */
function onDataChanged(hn,otext,ntext,ovalue,nvalue,data) {
	var id = hn.xmlNode.getAttribute("id");
	sendDataChanged(id, ntext, nvalue);
	g_oEditorContainer.updateValue(id, ntext);
}

function sendDataChanged(id, ntext, nvalue) {
	var soap = new HWSOAP("/hwsvr2/re");
	var str = "<cid>"+g_cid+"</cid><da>";
	str += "<d id='"+id+"'";
	if(null != nvalue) {
		var idx,a = nvalue.split('&');
		for (var i = 0; i< a.length; i++) {
			idx = a[i].indexOf('=');
			str += " _" + a[i].substr(0,idx) + "='" + unescape(unescape(a[i].substr(idx+1))) +"'";
		}
	}
	str += ">"+ntext+"</d>";
	str += "</da>";

	soap.addRequest("updateData", null, str);
	soap.send();
	var sr = soap.getResult();
	if (sr==null) {
		soap.showErrors();
		return;
	}
	//dalert(sr.selectSingleNode("da").xml);
	var lst = sr.selectNodes("da/d");
	for (var i = 0; i < lst.length; i++) {
		var obj = lst[i];
		g_oEditorContainer.updateValue(obj.getAttribute("id"), obj.text);
	}
}
var HW_DATA_CONTROL = "HW_DATA_CONTROL";
